<!DOCTYPE html>
<!--
  Copyright 2018 Google Inc.

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
-->
<html>
  <head>
    <meta charset="utf-8">
    <title>Tab Indicator - Material Components Catalog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png">
    <link rel="stylesheet" href="/assets/tab-indicator.css">
    <script src="/ready.js"></script>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  </head>

  <body class="mdc-typography">
    <header class="mdc-toolbar mdc-toolbar--fixed">
      <div class="mdc-toolbar__row">
        <section class="mdc-toolbar__section mdc-toolbar__section--align-start">
          <span class="catalog-back">
            <a href="/" class="mdc-toolbar__menu-icon"><i class="material-icons">&#xE5C4;</i></a>
          </span>
          <span class="mdc-toolbar__title catalog-title">Tab Indicator</span>
        </section>
      </div>
    </header>

    <main class="mdc-toolbar-fixed-adjust">
      <section class="hero">
        <div class="demo">
          <div class="demo-item hero-demo-item">
            <span class="mdc-tab-indicator mdc-tab-indicator--active">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--wide hero-demo-item">
            <span class="mdc-tab-indicator">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--narrow hero-demo-item">
            <span class="mdc-tab-indicator">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
        </div>
      </section>

      <section class="example">
        <h2>Sliding Underline Indicator</h2>
        <div class="demo">
          <div class="demo-item">
            <span class="mdc-tab-indicator mdc-tab-indicator--active demo-indicator custom-sliding-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator custom-sliding-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator custom-sliding-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
        </div>

        <br>

        <h4>Custom Color</h4>
        <div class="demo">
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator mdc-tab-indicator--active custom-color-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item">
            <span class="mdc-tab-indicator custom-color-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator custom-color-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
        </div>

        <br>

        <h4>Custom Height</h4>
        <div class="demo">
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator mdc-tab-indicator--active custom-height-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator custom-height-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item">
            <span class="mdc-tab-indicator custom-height-underline">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
        </div>

        <br>

        <h4>Custom Border Radius</h4>
        <div class="demo">
          <div class="demo-item">
            <span class="mdc-tab-indicator mdc-tab-indicator--active custom-border-radius">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator custom-border-radius">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator custom-border-radius">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
            </span>
          </div>
        </div>
      </section>

      <section class="example">
        <h2>Fading Icon Indicator</h2>
        <div class="demo">
          <div class="demo-item">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade mdc-tab-indicator--active">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">favorite</span>
            </span>
          </div>
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">star</span>
            </span>
          </div>
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">lens</span>
            </span>
          </div>
        </div>

        <br>

        <h4>Custom Color</h4>
        <div class="demo">
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade mdc-tab-indicator--active custom-color-icon">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">favorite</span>
            </span>
          </div>
          <div class="demo-item">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade custom-color-icon">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">star</span>
            </span>
          </div>
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade custom-color-icon">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">lens</span>
            </span>
          </div>
        </div>

        <br>

        <h4>Custom Height</h4>
        <div class="demo">
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade mdc-tab-indicator--active custom-height-icon">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">favorite</span>
            </span>
          </div>
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade custom-height-icon">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">star</span>
            </span>
          </div>
          <div class="demo-item">
            <span class="mdc-tab-indicator mdc-tab-indicator--fade custom-height-icon">
              <span class="mdc-tab-indicator__content mdc-tab-indicator__content--icon material-icons">lens</span>
            </span>
          </div>
        </div>
      </section>

      <section class="example">
        <h2>Mix and Match</h2>
        <p>This demo shows how to use a sliding indicator with custom SVG icon content.</p>
        <div class="demo">
          <div class="demo-item">
            <span class="mdc-tab-indicator mdc-tab-indicator--active custom-sliding-icon">
              <svg class="mdc-tab-indicator__content mdc-tab-indicator__content--icon custom-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                <path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"/>
                <path fill="none" d="M0 0h24v24H0V0z"/>
              </svg>
            </span>
          </div>
          <div class="demo-item demo-item--narrow">
            <span class="mdc-tab-indicator custom-sliding-icon">
              <svg class="mdc-tab-indicator__content mdc-tab-indicator__content--icon custom-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                <path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"/>
                <path fill="none" d="M0 0h24v24H0V0z"/>
              </svg>
            </span>
          </div>
          <div class="demo-item demo-item--wide">
            <span class="mdc-tab-indicator custom-sliding-icon">
              <svg class="mdc-tab-indicator__content mdc-tab-indicator__content--icon custom-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                <path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"/>
                <path fill="none" d="M0 0h24v24H0V0z"/>
              </svg>
            </span>
          </div>
        </div>
      </section>
    </main>

    <script src="/assets/material-components-web.js" async></script>
    <script>
      demoReady(function() {

        function initDemo(demoRoot) {
          var demoItems = demoRoot.querySelectorAll('.demo-item');
          var activeIndicator;
          [].forEach.call(demoItems, function (demoItem) {
            var indicatorEl = demoItem.querySelector('.mdc-tab-indicator');
            var indicator = new mdc.tabIndicator.MDCTabIndicator(indicatorEl);
            if (indicatorEl.classList.contains('mdc-tab-indicator--active')) {
              activeIndicator = indicator;
            }

            demoItem.addEventListener('click', function() {
              activeIndicator.deactivate();
              indicator.activate(activeIndicator.computeContentClientRect());
              activeIndicator = indicator;
            });
          });
        }

        var demos = document.querySelectorAll('.demo');
        [].forEach.call(demos, initDemo);
      });
    </script>
  </body>
</html>
